home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / tsm23s.lha / iffp / iff.h < prev    next >
C/C++ Source or Header  |  1993-10-05  |  5KB  |  178 lines

  1. /* 
  2.  *
  3.  * iff.h:    General Definitions for IFFParse modules
  4.  *
  5.  * 10/20/91
  6.  */
  7.  
  8. // Minor changes MJP
  9.  
  10. #ifndef IFFP_IFF_H
  11. #define IFFP_IFF_H
  12.  
  13. #include "iffp/compiler.h"
  14.  
  15. #ifndef EXEC_TYPES_H
  16. #include <exec/types.h>
  17. #endif
  18. #ifndef EXEC_MEMORY_H
  19. #include <exec/memory.h>
  20. #endif
  21. #ifndef UTILITY_TAGITEM_H
  22. #include <utility/tagitem.h>
  23. #endif
  24. #ifndef UTILITY_HOOKS_H
  25. #include <utility/hooks.h>
  26. #endif
  27. #ifndef LIBRARIES_IFFPARSE_H
  28. #include <libraries/iffparse.h>
  29. #endif
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34.  
  35. #ifndef MYDEBUG_H
  36. #include "iffp/debug.h"
  37. #endif
  38.  
  39.  
  40. #ifndef NO_PROTOS
  41. #include <clib/exec_protos.h>
  42. #include <clib/utility_protos.h>
  43. #include <clib/iffparse_protos.h>
  44. #endif
  45. #ifndef NO_SAS_PRAGMAS
  46. extern struct Library *SysBase;
  47. #include <pragmas/exec_pragmas.h>
  48. extern struct Library *IFFParseBase;
  49. #include <pragmas/iffparse_pragmas.h>
  50. extern struct Library *DOSBase;
  51. #include <pragmas/dos_pragmas.h>
  52. #endif
  53.  
  54. #ifndef MAX
  55. #define    MAX(a,b)    ((a) > (b) ? (a) : (b))
  56. #endif
  57. #ifndef MIN
  58. #define    MIN(a,b)    ((a) < (b) ? (a) : (b))
  59. #endif
  60. #ifndef ABS
  61. #define    ABS(x)        ((x) < 0 ? -(x) : (x))
  62. #endif
  63.  
  64. /* Locale stuff */
  65. #include "iffp/iffpstringids.h"
  66.  
  67. #ifndef TEXTTABLE_H
  68. struct AppString
  69. {
  70.     LONG   as_ID;
  71.     STRPTR as_Str;
  72. };
  73. #endif
  74.  
  75. extern struct  AppString AppStrings[];
  76. #define SI(i)  XGetString(i)                // Was GetString() MJP (used by GadToolsBox)
  77.  
  78.  
  79. #define CkErr(expression)  {if (!error) error = (expression);}
  80. #define ChunkMoreBytes(cn)    (cn->cn_Size - cn->cn_Scan)
  81. #define IS_ODD(a)        (a & 1)
  82.  
  83. #define IFF_OKAY    0L
  84. #define    CLIENT_ERROR    1L
  85. #define NOFILE          5L
  86.  
  87. VOID Error(char *ErrorMessage,char *Gadget,char *extra,ULONG helpnum);    // MJP
  88. #define message(a,b,c) Error(a,"OK",b,c)                            // MJP
  89.  
  90. /* Generic Chunk ID's we may encounter */
  91. #define    ID_ANNO        MAKE_ID('A','N','N','O')
  92. #define    ID_AUTH        MAKE_ID('A','U','T','H')
  93. #define    ID_CHRS        MAKE_ID('C','H','R','S')
  94. #define    ID_Copyright    MAKE_ID('(','c',')',' ')
  95. #define    ID_CSET        MAKE_ID('C','S','E','T')
  96. #define    ID_FVER        MAKE_ID('F','V','E','R')
  97. #define    ID_NAME        MAKE_ID('N','A','M','E')
  98. #define ID_TEXT        MAKE_ID('T','E','X','T')
  99. #define ID_BODY        MAKE_ID('B','O','D','Y')
  100.  
  101.  
  102. /* Used to keep track of allocated IFFHandle, and whether file is
  103.  * clipboard or not, filename, copied chunks, etc.
  104.  * This structure is included in the beginning of every
  105.  * form-specific info structure used by the example modules.
  106.  */
  107. struct ParseInfo {
  108.     /* general parse.c related */
  109.     struct  IFFHandle *iff;        /* to be alloc'd with AllocIFF */
  110.     UBYTE    *filename;        /* current filename of this ui */
  111.     LONG    *propchks;        /* properties to get */
  112.     LONG    *collectchks;        /* properties to collect */
  113.     LONG    *stopchks;        /* stop on these (like BODY) */
  114.     BOOL    opened;            /* this iff has been opened */
  115.     BOOL    clipboard;        /* file is clipboard */
  116.     BOOL    hunt;            /* we are parsing a complex file */
  117.     BOOL    Reserved1;        /* must be zero for now */        
  118.  
  119.     /* for copychunks.c - for read/modify/write programs
  120.      * and programs that need to keep parsed chunk info
  121.      * around after closing file.
  122.      * Deallocated by freechunklist();
  123.      */
  124.     struct Chunk *copiedchunks;
  125.  
  126.     /* application may hang its own list of new chunks here
  127.      * just to keep it with the frame.
  128.      */
  129.     struct Chunk *newchunks;
  130.  
  131.     ULONG    Reserved[8];
  132.     };
  133.  
  134.  
  135. /*
  136.  * Used by some modules to save or pass a singly linked list of chunks
  137.  */
  138. struct Chunk {
  139.     struct  Chunk *ch_Next;
  140.     long    ch_Type;
  141.     long    ch_ID;
  142.         long    ch_Size;
  143.         void    *ch_Data;
  144. };
  145.  
  146.  
  147. #ifndef NO_PROTOS
  148. /* parse.c */
  149. LONG openifile(struct ParseInfo *pi,UBYTE *filename, ULONG iffopenmode);
  150. void closeifile(struct ParseInfo *pi);
  151. LONG parseifile(struct ParseInfo *pi,LONG groupid,LONG grouptype,
  152.     LONG *propchks,LONG *collectchks,LONG *stopchks);
  153. LONG getcontext(struct IFFHandle *iff);
  154. LONG nextcontext(struct IFFHandle *iff);
  155. LONG currentchunkis(struct IFFHandle *iff, LONG type, LONG id);
  156. LONG contextis(struct IFFHandle *iff, LONG type, LONG id);
  157. UBYTE *findpropdata(struct IFFHandle *iff, LONG type, LONG id);
  158. void initiffasstdio(struct IFFHandle *iff);
  159. LONG chkcnt(LONG *taggedarray);
  160. long PutCk(struct IFFHandle *iff, long id, long size, void *data);
  161.  
  162. /* iffpstrings.c */
  163. UBYTE *openScreenErr(ULONG errorcode);
  164. UBYTE *IFFerr(LONG error);
  165. void OpenStrings(void);
  166. void CloseStrings(void);
  167. UBYTE *XGetString(ULONG id);            // MJP was GetString() (used by GadToolsBox)
  168.  
  169. /* copychunks.c */
  170. struct Chunk *copychunks(struct IFFHandle *iff,
  171.                  LONG *propchks, LONG *collectchks, ULONG memtype);
  172. void freechunklist(struct Chunk *first);
  173. struct Chunk *findchunk(struct Chunk *first, long type, long id);
  174. long writechunklist(struct IFFHandle *iff, struct Chunk *first);
  175. #endif /* NO_PROTOS */
  176.  
  177. #endif /* IFFP_IFF_H */
  178.